home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 176-200 / disk_183 / mklib / edlib / strpos.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  470b  |  24 lines

  1. /* edlib  version 1.0 of 04/08/88 */
  2. /*
  3.     strpos searches the null-terminated string string for the first
  4.     occurance of the character "key". It returns either the position
  5.     or EOF if it is not found.
  6. */
  7.  
  8. int strpos(string,key)
  9. char *string;
  10. char key;
  11. {
  12.     int counter = 0;
  13.  
  14.     if ( !key )
  15.         return(strlen(string));
  16.  
  17.     while (string[counter]) {
  18.         if (string[counter] == key)
  19.             return(counter);
  20.         counter++;
  21.     }
  22.     return(-1);
  23. }
  24.